<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::get('/user', function (Request $request) {
    return $request->user();
});

/*
 * Api Interface Routes
 * Namespaces indicate folder structure
 */
Route::group(['as' => 'api.', 'middleware' => 'guest.api'], function () {
    Route::resource('login', 'LoginAPIController', ['only' => ['store', 'index']]);
    Route::resource('register', 'RegisterAPIController', ['only' => ['store']]);
});

/*
 * Api Interface Routes
 * Namespaces indicate folder structure
 */
Route::group(['as' => 'api.', 'middleware' => 'auth.api'], function () {

});

Route::post('wechat_mini_program', 'WechatMiniProgramController@login');
Route::put('wechat_mini_program', 'WechatMiniProgramController@updateWxUserInfo');

Route::resource('wechat_users', 'WechatUserAPIController', ['only' => 'update']);

Route::resource('announcements', 'AnnouncementAPIController');

Route::resource('user_uploads', 'UserUploadAPIController', ['only' => ['store']]);

Route::resource('items', 'ItemAPIController');
Route::get('items/{items}/orders', 'ItemAPIController@indexOrders');
Route::get('items/{items}/orders/{orders}', 'ItemAPIController@showOrder');
Route::get('items/{items}/channels', 'ItemAPIController@indexChannels');
Route::get('items/{items}/channels/{channels}', 'ItemAPIController@showChannel');
Route::get('items/{items}/channels/{channels}/users', 'ItemAPIController@indexChannelUsers');
Route::post('items/{items}/managers', 'ItemAPIController@storeManagers');
Route::delete('items/{items}/managers/{managers}', 'ItemAPIController@destroyManagers');
Route::post('items/{items}/channels/{channels}/cooperations', 'ItemAPIController@storeChannelCooperations');
Route::put('items/{items}/channels/{channels}/cooperations', 'ItemAPIController@updateChannelCooperations');

// Route::resource('item_contracts', 'ItemContractAPIController');

Route::resource('channels', 'ChannelAPIController');
Route::get('channels/{channels}/index', 'ChannelAPIController@showIndex');
Route::get('channels/{channels}/visit_days', 'ChannelAPIController@showVisitDays');
Route::get('channels/{channels}/visit_users', 'ChannelAPIController@showVisitUsers');
Route::get('channels/{channels}/relay_days', 'ChannelAPIController@showRelayDays');
Route::get('channels/{channels}/relay_users', 'ChannelAPIController@showRelayUsers');
Route::post('channels/{channels}/orders', 'ChannelAPIController@storeOrders');
Route::get('channels/{channels}/orders', 'ChannelAPIController@indexOrders');
Route::get('channels/{channels}/new_orders', 'ChannelAPIController@indexNewOrders');
Route::get('channels/{channels}/orders/{orders}', 'ChannelAPIController@showOrder');
Route::post('channels/{channels}/orders/{orders}/recommend', 'ChannelAPIController@storeOrderRecommend');
Route::get('channels/{channels}/users', 'ChannelAPIController@indexUsers');
Route::put('channels/{channels}/users/{users}', 'ChannelAPIController@updateUser');
Route::get('channels/{channels}/items', 'ChannelAPIController@indexItems');
Route::get('channels/{channels}/items/{items}', 'ChannelAPIController@showItem');
Route::get('channels/{channels}/users/{users}/items', 'ChannelAPIController@indexUserItems');
Route::post('channels/{channels}/managers', 'ChannelAPIController@storeManagers');
Route::delete('channels/{channels}/managers/{managers}', 'ChannelAPIController@destroyManagers');
Route::post('channels/{channels}/items/{items}/cooperations', 'ChannelAPIController@storeItemCooperations');
Route::put('channels/{channels}/items/{items}/cooperations', 'ChannelAPIController@updateItemCooperations');
Route::post('channels/{channels}/items/{items}/open', 'ChannelAPIController@storeItemOpens');

Route::resource('houses', 'HouseAPIController');

// Route::resource('wechat_user_sessions', 'WechatUserSessionAPIController');

// Route::resource('cooperations', 'CooperationAPIController', ['only' => ['show', 'update']]);

// Route::resource('channel_orders', 'ChannelOrderAPIController');

// Route::resource('item_orders', 'ItemOrderAPIController');

// Route::resource('channel_visit_days', 'ChannelVisitDayAPIController');

// Route::resource('channel_visit_users', 'ChannelVisitUserAPIController');

// Route::resource('channel_managers', 'ChannelManagerAPIController');

// Route::resource('item_managers', 'ItemManagerAPIController');

// Route::resource('channel_users', 'ChannelUserAPIController');

// Route::resource('channel_user_items', 'ChannelUserItemAPIController');

// Route::resource('channel_order_reads', 'ChannelOrderReadAPIController');

// Route::resource('item_order_reads', 'ItemOrderReadAPIController');

// Route::resource('channel_relay_days', 'ChannelRelayDayAPIController');

// Route::resource('channel_relay_users', 'ChannelRelayUserAPIController');